#include <iostream>
#include <vector>
#include <cstdio> 
#include <algorithm>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int >  vec;
typedef pair < int , int > pii;

int read() {
  int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
  while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 5e5 + 10;

int h[N],cnt,n,m,K;
vec ans;
bool vis[N];
struct edge { int v,nxt; } e[N << 2];
void link(int x,int y) { e[++cnt] = (edge) { y,h[x] }; h[x] = cnt; }

void dfs(int x,int d) {
    vis[x] = 1; if(d == 2) return; for(int i = h[x];i;i = e[i].nxt) dfs(e[i].v,d + 1);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in,m = in,K = in; for(int i = 1,u,v;i <= m;i++) u = in,v = in,link(u,v),link(v,u);
    for(int i = 1;i <= n;i++)
	if(!vis[i]) {
	    ans.pb(i); dfs(i,0);
	}
    printf("%llu\n",ans.size()); sort(ans.begin(),ans.end()); for(auto x : ans) printf("%d ",x); return 0;
} 
